package com.lxj.utils;

/**
 * ClickHouse工具类 - 使用JDBC连接器
 */
public class ClickHouseUtil {

    /**
     * 获取ClickHouse JDBC Sink DDL
     */
    public static String getClickHouseSinkDDL(String tableName) {
        return "WITH (\n" +
                "  'connector' = 'jdbc',\n" +
                "  'url' = 'jdbc:clickhouse://hadoop102:8123/gmall',\n" +
                "  'table-name' = '" + tableName + "',\n" +
                "  'username' = 'default',\n" +
                "  'password' = '',\n" +
                "  'driver' = 'ru.yandex.clickhouse.ClickHouseDriver',\n" +
                "  'sink.buffer-flush.max-rows' = '100',\n" +
                "  'sink.buffer-flush.interval' = '1000',\n" +
                "  'sink.max-retries' = '3'\n" +
                ")";
    }

    /**
     * 获取Kafka到ClickHouse的完整DDL（包含字段映射）
     */
    public static String getKafkaToClickHouseDDL(String kafkaTopic, String clickhouseTable) {
        return "WITH (\n" +
                "  'connector' = 'jdbc',\n" +
                "  'url' = 'jdbc:clickhouse://hadoop102:8123/gmall',\n" +
                "  'table-name' = '" + clickhouseTable + "',\n" +
                "  'username' = 'default',\n" +
                "  'password' = '',\n" +
                "  'driver' = 'ru.yandex.clickhouse.ClickHouseDriver',\n" +
                "  'sink.buffer-flush.max-rows' = '100',\n" +
                "  'sink.buffer-flush.interval' = '1000'\n" +
                ")";
    }
}